|
|
|
|
|
|
|
Note In accessing ODBC drivers, your application architecture needs to be designed carefully. You should pay special attention to the SQLBindCol function. Although you can pass the address of a string variable to SQLBindCol, strings in Visual Basic are moved in memory without notice. This could render your use of SQLBindCol ineffective (and even cause application problems) if you don't explicitly lock the memory space of the variable. You could also use Byte arrays that aren't subject to Visual Basic's need to reallocate string variable memory spaces. |
|
|
|
| | In the openDBResultset, you would have a private method, bindColumn, that is called from within the public interface method, openDBResultset. One reason for having a separate method is that the SQLBindCol method requires many methods, some of which might necessitate special code on your part. Having this separate method, then, would better organize your typically complex ODBC code. In an appropriate module (you should probably name it modODBC), you would have the following declaration: | Declare Function SQLBindCol Lib odbc.dll _
Alias SqlBindCol _
(ByVal hstmt As Long, ByVal icol As Integer,
ByVal fCType As Integer, rgbValue As Any, _
ByVal cbValueMax As Long, pcbValue As Long) _
As Integer | | Fortunately, the class structures you use for wrapping ODBC API calls behind facades are the same class structures you can use for wrapping VBSQL and Oracle Objects calls. For the sake of brevity, these data access mechanisms aren't detailed in this chapter. Nevertheless, it shouldn't be at all difficult because popular data access mechanisms in the industry have much the same look and feel. |
|
|
|
|
|
Keeping Data Controls in Their Proper Perspective |
|
|
|
|
|
|
|
|
When you begin developing applications in Visual Basic and are faced with a pressing deadline, Data controls are electronic lifesavers. Just place a control on a form, set a few attributes on bound controls, and you've created powerful access to an ODBC-compliant or Jet-based data source. Your customers are happy, your project manager is happy, and you're happyor are you? |
|
|
|
|
|
|
|
|
Sometimes, the seeming ease of the Data control can be quickly eclipsed by the awkwardness of reusing database code across many forms and the failure of the Data control's underlying mechanism. |
|
|
|
|
|